
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>utils · 合同管理</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Gj">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-tomorrow.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../styles/website.css">
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="views/" />
    
    
    <link rel="prev" href="styles.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    概要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Framework.html">
            
                <a href="../Framework.html">
            
                    
                    架构
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">src目录</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="api.html">
            
                <a href="api.html">
            
                    
                    api
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="assets.html">
            
                <a href="assets.html">
            
                    
                    assets
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="components.html">
            
                <a href="components.html">
            
                    
                    components
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="filters.html">
            
                <a href="filters.html">
            
                    
                    filters
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="mixins.html">
            
                <a href="mixins.html">
            
                    
                    mixins
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="router.html">
            
                <a href="router.html">
            
                    
                    router
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="store.html">
            
                <a href="store.html">
            
                    
                    store
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="styles.html">
            
                <a href="styles.html">
            
                    
                    styles
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.9" data-path="utils.html">
            
                <a href="utils.html">
            
                    
                    utils
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="views/">
            
                <a href="views/">
            
                    
                    views
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.10.1" data-path="views/activate.html">
            
                <a href="views/activate.html">
            
                    
                    activate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.2" data-path="views/approvemanage.html">
            
                <a href="views/approvemanage.html">
            
                    
                    approvemanage
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.3" data-path="views/sealmanage.html">
            
                <a href="views/sealmanage.html">
            
                    
                    sealmanage
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.4" data-path="views/deptmanage.html">
            
                <a href="views/deptmanage.html">
            
                    
                    deptmanage
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.5" data-path="views/faildoc.html">
            
                <a href="views/faildoc.html">
            
                    
                    faildoc
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.6" data-path="views/files.html">
            
                <a href="views/files.html">
            
                    
                    files
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.7" data-path="views/init.html">
            
                <a href="views/init.html">
            
                    
                    init
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.8" data-path="views/layout.html">
            
                <a href="views/layout.html">
            
                    
                    layout
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.9" data-path="views/login.html">
            
                <a href="views/login.html">
            
                    
                    login
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.10" data-path="views/myfiles.html">
            
                <a href="views/myfiles.html">
            
                    
                    myfiles
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.11" data-path="views/passmail.html">
            
                <a href="views/passmail.html">
            
                    
                    passmail
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.12" data-path="views/redirect.html">
            
                <a href="views/redirect.html">
            
                    
                    redirect
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.13" data-path="views/sysmanage.html">
            
                <a href="views/sysmanage.html">
            
                    
                    sysmanage
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.14" data-path="views/template.html">
            
                <a href="views/template.html">
            
                    
                    template
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.15" data-path="views/updateinfo.html">
            
                <a href="views/updateinfo.html">
            
                    
                    updateinfo
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10.16" data-path="views/usermanage.html">
            
                <a href="views/usermanage.html">
            
                    
                    usermanage
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2.11" data-path="config.html">
            
                <a href="config.html">
            
                    
                    配置文件
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.12" data-path="newPage.html">
            
                <a href="newPage.html">
            
                    
                    新建页面
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >utils</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h3 id="&#x5DE5;&#x5177;&#x5305;">&#x5DE5;&#x5177;&#x5305;</h3>
<h5 id="indexjs">index.js</h5>
<p>&#x81EA;&#x5B9A;&#x4E49;&#x5DE5;&#x5177;&#x5305;&#x4E3B;&#x6587;&#x4EF6;</p>
<pre class="language-"><code class="lang-javascript"><span class="token comment">/**
 * &#x5DE5;&#x5177;&#x680F; &#x641C;&#x7D22;
 * @param {*} listQuery &#x641C;&#x7D22;&#x53C2;&#x6570; 
 * @param {*} keyWords &#x5173;&#x952E;&#x8BCD;&#x67E5;&#x8BE2;&#xFF0C;&#x9488;&#x5BF9;&#x65F6;&#x95F4;&#x533A;&#x95F4;&#x67E5;&#x8BE2;
 */</span>
<span class="token keyword">export</span> <span class="token keyword">function</span> <span class="token function">searchTool</span><span class="token punctuation">(</span><span class="token parameter">listQuery<span class="token punctuation">,</span> keyWords<span class="token operator">=</span><span class="token keyword">null</span></span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token keyword">let</span> query <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
  <span class="token keyword">if</span><span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">isNull</span><span class="token punctuation">(</span>keyWords<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">{</span><span class="token comment">//&#x5220;&#x9664;&#x5173;&#x952E;&#x8BCD;&#x7684;key</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">let</span> i <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> i <span class="token operator">&lt;</span> keyWords<span class="token punctuation">.</span>names<span class="token punctuation">.</span>length<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">let</span> name <span class="token operator">=</span> keyWords<span class="token punctuation">.</span>names<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">;</span>
      <span class="token keyword">delete</span> listQuery<span class="token punctuation">[</span>name<span class="token punctuation">]</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
  <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">let</span> key <span class="token keyword">in</span> listQuery<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>listQuery<span class="token punctuation">.</span><span class="token function">hasOwnProperty</span><span class="token punctuation">(</span>key<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">let</span> element <span class="token operator">=</span> listQuery<span class="token punctuation">[</span>key<span class="token punctuation">]</span><span class="token punctuation">;</span>
      <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">isNull</span><span class="token punctuation">(</span>element<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        query<span class="token punctuation">[</span>key<span class="token punctuation">]</span> <span class="token operator">=</span> element
      <span class="token punctuation">}</span>
      <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">isNull</span><span class="token punctuation">(</span>keyWords<span class="token punctuation">)</span> <span class="token operator">&amp;&amp;</span> key <span class="token operator">==</span> keyWords<span class="token punctuation">.</span>key <span class="token operator">&amp;&amp;</span> <span class="token operator">!</span><span class="token function">isNull</span><span class="token punctuation">(</span>element<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">let</span> formate <span class="token operator">=</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
        <span class="token keyword">if</span><span class="token punctuation">(</span>element<span class="token punctuation">.</span>constructor <span class="token operator">===</span> String<span class="token punctuation">)</span><span class="token punctuation">{</span>
          <span class="token punctuation">[</span>formate<span class="token punctuation">[</span>keyWords<span class="token punctuation">.</span>names<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">,</span> formate<span class="token punctuation">[</span>keyWords<span class="token punctuation">.</span>names<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">[</span>element <span class="token operator">+</span> <span class="token string">&apos; 00:00:00&apos;</span><span class="token punctuation">,</span> element <span class="token operator">+</span> <span class="token string">&apos; 23:59:59&apos;</span><span class="token punctuation">]</span>
        <span class="token punctuation">}</span><span class="token keyword">else</span> <span class="token keyword">if</span><span class="token punctuation">(</span>element<span class="token punctuation">.</span>constructor <span class="token operator">===</span> Array<span class="token punctuation">)</span><span class="token punctuation">{</span>
          <span class="token punctuation">[</span>formate<span class="token punctuation">[</span>keyWords<span class="token punctuation">.</span>names<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">,</span> formate<span class="token punctuation">[</span>keyWords<span class="token punctuation">.</span>names<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token operator">=</span> <span class="token punctuation">[</span>element<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span> <span class="token operator">+</span> <span class="token string">&apos; 00:00:00&apos;</span><span class="token punctuation">,</span> element<span class="token punctuation">[</span><span class="token number">1</span><span class="token punctuation">]</span> <span class="token operator">+</span> <span class="token string">&apos; 23:59:59&apos;</span><span class="token punctuation">]</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">let</span> data <span class="token operator">=</span> Object<span class="token punctuation">.</span><span class="token function">assign</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">,</span> formate<span class="token punctuation">,</span> query<span class="token punctuation">)</span><span class="token punctuation">;</span>
        query <span class="token operator">=</span> data<span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
  <span class="token keyword">return</span> query<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token operator">...</span>
</code></pre>
<h5 id="enumfenum">Enum/FEnum</h5>
<p>&#x670D;&#x52A1;&#x7AEF;&#x679A;&#x4E3E;&#x5B9A;&#x4E49;</p>
<pre class="language-"><code class="lang-javascript"><span class="token comment">/**
 * &#x7528;&#x6237;&#x89D2;&#x8272;
 * enum for UserRole
 * @readonly
 * @enum {Number}
 */</span>
exports<span class="token punctuation">.</span>UserRole <span class="token operator">=</span> <span class="token punctuation">{</span>
  normal<span class="token operator">:</span> <span class="token number">0</span> <span class="token comment">/**&#x666E;&#x901A;&#x7528;&#x6237; */</span><span class="token punctuation">,</span>
  auditor<span class="token operator">:</span> <span class="token number">1</span> <span class="token comment">/**&#x6587;&#x4E66;&#x5BA1;&#x67E5;&#x62C5;&#x5F53; */</span><span class="token punctuation">,</span>
  sealer<span class="token operator">:</span> <span class="token number">2</span> <span class="token comment">/**&#x76D6;&#x7AE0;&#x62C5;&#x5F53; */</span><span class="token punctuation">,</span>
  taxer<span class="token operator">:</span> <span class="token number">3</span> <span class="token comment">/**&#x514D;&#x7A0E;&#x5904;&#x7406;&#x62C5;&#x5F53; */</span><span class="token punctuation">,</span>
  archiver<span class="token operator">:</span> <span class="token number">4</span> <span class="token comment">/**&#x5B58;&#x6863;&#x5904;&#x7406;&#x62C5;&#x5F53; */</span><span class="token punctuation">,</span>
  bscSealer<span class="token operator">:</span> <span class="token number">5</span> <span class="token comment">/**bsc&#x90E8;&#x95E8;&#x5408;&#x540C;&#x62C5;&#x5F53; */</span><span class="token punctuation">,</span>
  businesser<span class="token operator">:</span> <span class="token number">6</span> <span class="token comment">/**&#x4E8B;&#x4E1A;&#x90E8;&#x5408;&#x540C;&#x62C5;&#x5F53; */</span><span class="token punctuation">,</span>
  sealSaver<span class="token operator">:</span> <span class="token number">8</span> <span class="token comment">/**&#x538B;&#x5370;&#x62C5;&#x5F53; */</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
</code></pre>
<h5 id="enumvenum">Enum/VEnum</h5>
<p>&#x524D;&#x7AEF;&#x679A;&#x4E3E;&#x5B9A;&#x4E49;</p>
<pre class="language-"><code class="lang-javascript"><span class="token comment">/**
 * &#x670D;&#x52A1;&#x7AEF; &#x7528;&#x6237;&#x7B49;&#x7EA7;
 */</span>
exports<span class="token punctuation">.</span>SUserLevelEnum <span class="token operator">=</span> <span class="token punctuation">{</span>
    <span class="token keyword">class</span><span class="token operator">:</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token comment">/* &#x8BFE;&#x957F; */</span>
    dept<span class="token operator">:</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token comment">/* &#x90E8;&#x957F; */</span>
    center<span class="token operator">:</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token comment">/* &#x4E2D;&#x5FC3;&#x957F; */</span>
    boss<span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token comment">/* &#x603B;&#x7ECF;&#x7406; */</span>
<span class="token punctuation">}</span>

<span class="token comment">/**
 * &#x5BA2;&#x6237;&#x7AEF; &#x7B49;&#x7EA7;&#x5BF9;&#x5E94; &#x7528;&#x6237;
 */</span>
exports<span class="token punctuation">.</span>CUserLevelEnum <span class="token operator">=</span> <span class="token punctuation">{</span>
    <span class="token keyword">class</span><span class="token operator">:</span> <span class="token number">1</span><span class="token punctuation">,</span> <span class="token comment">/* &#x8BFE;&#x957F; */</span>
    dept<span class="token operator">:</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token comment">/* &#x90E8;&#x957F; */</span>
    center<span class="token operator">:</span> <span class="token number">3</span><span class="token punctuation">,</span> <span class="token comment">/* &#x4E2D;&#x5FC3;&#x957F; */</span>
    boss<span class="token operator">:</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token comment">/* &#x603B;&#x7ECF;&#x7406; */</span>
<span class="token punctuation">}</span>
</code></pre>
<h5 id="i18njs">i18n.js</h5>
<p>&#x56FD;&#x9645;&#x5316;&#x83DC;&#x5355;&#x8F6C;&#x4E49;&#x6587;&#x4EF6;</p>
<pre class="language-"><code class="lang-javascript"><span class="token comment">// translate router.meta.title, be used in breadcrumb sidebar tagsview</span>
<span class="token keyword">export</span> <span class="token keyword">function</span> <span class="token function">generateTitle</span><span class="token punctuation">(</span><span class="token parameter">title</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">const</span> hasKey <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">$te</span><span class="token punctuation">(</span><span class="token string">&apos;route.&apos;</span> <span class="token operator">+</span> title<span class="token punctuation">)</span>

  <span class="token keyword">if</span> <span class="token punctuation">(</span>hasKey<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token comment">// $t :this method from vue-i18n, inject in @/lang/index.js</span>
    <span class="token keyword">const</span> translatedTitle <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">$t</span><span class="token punctuation">(</span><span class="token string">&apos;route.&apos;</span> <span class="token operator">+</span> title<span class="token punctuation">)</span>

    <span class="token keyword">return</span> translatedTitle
  <span class="token punctuation">}</span>
  <span class="token keyword">return</span> title
<span class="token punctuation">}</span>
</code></pre>
<h5 id="requestjs">request.js</h5>
<p>api&#x8BF7;&#x6C42;&#x5DE5;&#x5177;&#x3002;&#x63A5;&#x53E3;&#x5F02;&#x5E38;&#x62E6;&#x622A;&#x3002;</p>
<pre class="language-"><code class="lang-javascript"><span class="token keyword">import</span> axios <span class="token keyword">from</span> <span class="token string">&apos;axios&apos;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> Message<span class="token punctuation">,</span> MessageBox <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&apos;element-ui&apos;</span>
<span class="token keyword">import</span> store <span class="token keyword">from</span> <span class="token string">&apos;@/store&apos;</span>
<span class="token keyword">import</span> i18n <span class="token keyword">from</span> <span class="token string">&apos;@/lang&apos;</span>
<span class="token keyword">import</span> router <span class="token keyword">from</span> <span class="token string">&apos;@/router&apos;</span><span class="token punctuation">;</span>

<span class="token comment">// create an axios instance</span>
<span class="token keyword">const</span> service <span class="token operator">=</span> axios<span class="token punctuation">.</span><span class="token function">create</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  timeout<span class="token operator">:</span> <span class="token number">5000</span> <span class="token comment">// request timeout</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>

<span class="token comment">// request interceptor</span>
service<span class="token punctuation">.</span>interceptors<span class="token punctuation">.</span>request<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>
  <span class="token parameter">config</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
    config<span class="token punctuation">.</span>headers<span class="token punctuation">[</span><span class="token string">&apos;token&apos;</span><span class="token punctuation">]</span> <span class="token operator">=</span> localStorage<span class="token punctuation">.</span><span class="token function">getItem</span><span class="token punctuation">(</span><span class="token string">&quot;token&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">return</span> config
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token parameter">error</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
    Promise<span class="token punctuation">.</span><span class="token function">reject</span><span class="token punctuation">(</span>error<span class="token punctuation">)</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">)</span>

<span class="token comment">// response interceptor</span>
service<span class="token punctuation">.</span>interceptors<span class="token punctuation">.</span>response<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span> <span class="token parameter">response</span> <span class="token operator">=&gt;</span> response <span class="token punctuation">,</span> <span class="token parameter">error</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
    <span class="token keyword">const</span> <span class="token punctuation">{</span> status <span class="token punctuation">}</span> <span class="token operator">=</span> error<span class="token punctuation">.</span>response<span class="token punctuation">;</span>
    <span class="token keyword">let</span> <span class="token punctuation">{</span> errorCode<span class="token punctuation">,</span> errorMsg <span class="token punctuation">}</span> <span class="token operator">=</span> error<span class="token punctuation">.</span>response<span class="token punctuation">.</span>data<span class="token punctuation">;</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>status <span class="token operator">==</span> <span class="token number">500</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
      Message<span class="token punctuation">.</span><span class="token function">error</span><span class="token punctuation">(</span>i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&quot;request.500&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
      <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>status <span class="token operator">==</span> <span class="token number">504</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
      Message<span class="token punctuation">.</span><span class="token function">error</span><span class="token punctuation">(</span>i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&quot;request.504&quot;</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
      <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>errorCode <span class="token operator">===</span> <span class="token number">2017</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      MessageBox<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span>i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&quot;request.2017.msg&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&quot;request.2017.title&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        confirmButtonText<span class="token operator">:</span> i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&quot;request.2017.btn&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
        type<span class="token operator">:</span> <span class="token string">&apos;warning&apos;</span><span class="token punctuation">,</span> showClose<span class="token operator">:</span> <span class="token boolean">false</span>
      <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
        localStorage<span class="token punctuation">.</span><span class="token function">removeItem</span><span class="token punctuation">(</span><span class="token string">&quot;token&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        location<span class="token punctuation">.</span>href <span class="token operator">=</span> <span class="token string">&apos;/&apos;</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span><span class="token punctuation">)</span>
      <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>errorCode <span class="token operator">===</span> <span class="token number">2042</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      MessageBox<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span>i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">error[</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>errorCode<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">]</span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">{</span> type<span class="token operator">:</span> <span class="token string">&apos;warning&apos;</span><span class="token punctuation">,</span> showClose<span class="token operator">:</span> <span class="token boolean">false</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
        localStorage<span class="token punctuation">.</span><span class="token function">removeItem</span><span class="token punctuation">(</span><span class="token string">&quot;token&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        location<span class="token punctuation">.</span>href <span class="token operator">=</span> <span class="token string">&apos;/&apos;</span><span class="token punctuation">;</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span><span class="token punctuation">)</span>
      <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>errorCode <span class="token operator">===</span> <span class="token number">2005</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      MessageBox<span class="token punctuation">.</span><span class="token function">alert</span><span class="token punctuation">(</span>i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">error[</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>errorCode<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">]</span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
        type<span class="token operator">:</span> <span class="token string">&apos;warning&apos;</span><span class="token punctuation">,</span> showClose<span class="token operator">:</span> <span class="token boolean">false</span>
      <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
        localStorage<span class="token punctuation">.</span><span class="token function">removeItem</span><span class="token punctuation">(</span><span class="token string">&quot;token&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        router<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span><span class="token string">&quot;/&quot;</span><span class="token punctuation">)</span>
        <span class="token keyword">return</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span><span class="token punctuation">)</span>
      <span class="token keyword">return</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token function">Message</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
      message<span class="token operator">:</span> i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">error[</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>errorCode<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">]</span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      type<span class="token operator">:</span> <span class="token string">&apos;error&apos;</span><span class="token punctuation">,</span>
      duration<span class="token operator">:</span> <span class="token number">5</span> <span class="token operator">*</span> <span class="token number">1000</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token comment">//debug</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&apos;&gt;&gt; errorCode&#xFF1A;&apos;</span><span class="token punctuation">,</span> errorCode<span class="token punctuation">,</span> <span class="token string">&apos;,errorMsg&#xFF1A;&apos;</span><span class="token punctuation">,</span> errorMsg <span class="token punctuation">,</span> <span class="token string">&apos;&lt;&lt;&apos;</span><span class="token punctuation">)</span>
    <span class="token keyword">return</span> Promise<span class="token punctuation">.</span><span class="token function">reject</span><span class="token punctuation">(</span>error<span class="token punctuation">.</span>response<span class="token punctuation">.</span>data<span class="token punctuation">)</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">)</span>

<span class="token keyword">export</span> <span class="token keyword">default</span> service
</code></pre>
<h5 id="validatejs">validate.js</h5>
<p>&#x8868;&#x5355;&#x6821;&#x9A8C;&#x6587;&#x4EF6;&#xFF0C;&#x65E0;&#x9700;&#x518D;&#x66F4;&#x6539;</p>
<pre class="language-"><code class="lang-javascript">  <span class="token operator">...</span>

  <span class="token comment">/**
   * &#x53C2;&#x6570; item 
   * required true  &#x5FC5;&#x586B;&#x9879;
   * maxLength  &#x5B57;&#x7B26;&#x4E32;&#x7684;&#x6700;&#x5927;&#x957F;&#x5EA6;
   * min &#x548C; max &#x5FC5;&#x987B;&#x540C;&#x65F6;&#x7ED9; min &lt; max  type=number
   * type &#x624B;&#x673A;&#x53F7; mobile
   *      &#x90AE;&#x7BB1;   email
   *      &#x7F51;&#x5740;   url 
   *      &#x5404;&#x79CD;&#x81EA;&#x5B9A;&#x4E49;&#x7C7B;&#x578B;   &#x5B9A;&#x4E49;&#x5728; src/utils/validate &#x4E2D;    &#x6301;&#x7EED;&#x6DFB;&#x52A0;&#x4E2D;.......
   * */</span>

  <span class="token class-name">Vue</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span><span class="token function-variable function">filter_rules</span> <span class="token operator">=</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter">item</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token keyword">let</span> rules <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>item<span class="token punctuation">.</span>required<span class="token punctuation">)</span><span class="token punctuation">{</span>
      rules<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span><span class="token punctuation">{</span> required<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span> message<span class="token operator">:</span> i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&apos;validate.required&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> trigger<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&apos;blur&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;change&apos;</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>item<span class="token punctuation">.</span>maxLength<span class="token punctuation">)</span><span class="token punctuation">{</span>
      rules<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span><span class="token punctuation">{</span> min<span class="token operator">:</span><span class="token number">1</span><span class="token punctuation">,</span>max<span class="token operator">:</span>item<span class="token punctuation">.</span>maxLength<span class="token punctuation">,</span> message<span class="token operator">:</span> i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&apos;validate.maxLength.start&apos;</span><span class="token punctuation">)</span><span class="token operator">+</span>item<span class="token punctuation">.</span>maxLength<span class="token operator">+</span>i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&apos;validate.maxLength.end&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> trigger<span class="token operator">:</span> <span class="token string">&apos;blur&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>item<span class="token punctuation">.</span>min<span class="token operator">&amp;&amp;</span>item<span class="token punctuation">.</span>max<span class="token punctuation">)</span><span class="token punctuation">{</span>       
      rules<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span><span class="token punctuation">{</span> min<span class="token operator">:</span>item<span class="token punctuation">.</span>min<span class="token punctuation">,</span>max<span class="token operator">:</span>item<span class="token punctuation">.</span>max<span class="token punctuation">,</span> message<span class="token operator">:</span> i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&apos;validate.around.start&apos;</span><span class="token punctuation">)</span><span class="token operator">+</span>item<span class="token punctuation">.</span>min<span class="token operator">+</span>i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&apos;validate.around.center&apos;</span><span class="token punctuation">)</span><span class="token operator">+</span>item<span class="token punctuation">.</span>max<span class="token operator">+</span>i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&apos;validate.around.end&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> trigger<span class="token operator">:</span> <span class="token string">&apos;blur&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">if</span><span class="token punctuation">(</span>item<span class="token punctuation">.</span>type<span class="token punctuation">)</span><span class="token punctuation">{</span>
      <span class="token keyword">let</span> type <span class="token operator">=</span> item<span class="token punctuation">.</span>type<span class="token punctuation">;</span>
      <span class="token keyword">switch</span><span class="token punctuation">(</span>type<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">case</span> <span class="token string">&apos;email&apos;</span><span class="token operator">:</span>
            rules<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span><span class="token punctuation">{</span> type<span class="token operator">:</span> <span class="token string">&apos;email&apos;</span><span class="token punctuation">,</span> message<span class="token operator">:</span> i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&apos;validate.email&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> trigger<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&apos;blur&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;change&apos;</span><span class="token punctuation">]</span>  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token keyword">case</span> <span class="token string">&apos;upload&apos;</span><span class="token operator">:</span>
            rules<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span> <span class="token punctuation">{</span> required<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span> message<span class="token operator">:</span> i18n<span class="token punctuation">.</span><span class="token function">t</span><span class="token punctuation">(</span><span class="token string">&apos;validate.upload&apos;</span><span class="token punctuation">)</span><span class="token punctuation">,</span> trigger<span class="token operator">:</span> <span class="token string">&apos;change&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token keyword">case</span> <span class="token string">&apos;mobile&apos;</span><span class="token operator">:</span>
            rules<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span> <span class="token punctuation">{</span> validator<span class="token operator">:</span> isvalidateMobile<span class="token punctuation">,</span> trigger<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&apos;blur&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;change&apos;</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>    
        <span class="token keyword">case</span> <span class="token string">&apos;number&apos;</span><span class="token operator">:</span>
            rules<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span> <span class="token punctuation">{</span> validator<span class="token operator">:</span> isvalidateInteger<span class="token punctuation">,</span> trigger<span class="token operator">:</span> <span class="token string">&apos;blur&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token keyword">case</span> <span class="token string">&apos;price&apos;</span><span class="token operator">:</span>
            rules<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span> <span class="token punctuation">{</span> validator<span class="token operator">:</span> isPrice<span class="token punctuation">,</span> trigger<span class="token operator">:</span> <span class="token string">&apos;change&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token keyword">case</span> <span class="token string">&apos;port&apos;</span><span class="token operator">:</span>
              rules<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span> <span class="token punctuation">{</span> required<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span> validator<span class="token operator">:</span> isPort<span class="token punctuation">,</span> trigger<span class="token operator">:</span> <span class="token string">&apos;change&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
              <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token keyword">case</span> <span class="token string">&apos;account&apos;</span><span class="token operator">:</span> <span class="token comment">//&#x7528;&#x6237;&#x540D;&#x7EC4;&#x6210;&#x89C4;&#x5219;</span>
              rules<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span> <span class="token punctuation">{</span> required<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span> validator<span class="token operator">:</span> validAccount<span class="token punctuation">,</span> trigger<span class="token operator">:</span> <span class="token string">&apos;blur&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
              <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token keyword">case</span> <span class="token string">&apos;password&apos;</span><span class="token operator">:</span> <span class="token comment">//&#x5BC6;&#x7801;&#x7EC4;&#x6210;&#x89C4;&#x5219;</span>
              rules<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span> <span class="token punctuation">{</span> required<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span> validator<span class="token operator">:</span> validPass<span class="token punctuation">,</span> trigger<span class="token operator">:</span> <span class="token string">&apos;blur&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
              <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token keyword">case</span> <span class="token string">&apos;isEmpty&apos;</span><span class="token operator">:</span> <span class="token comment">//&#x975E;&#x7A7A;&#x6821;&#x9A8C;</span>
              rules<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span> <span class="token punctuation">{</span> required<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span> validator<span class="token operator">:</span> isEmpty<span class="token punctuation">,</span> trigger<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token string">&apos;blur&apos;</span><span class="token punctuation">,</span> <span class="token string">&apos;change&apos;</span><span class="token punctuation">]</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
              <span class="token keyword">break</span><span class="token punctuation">;</span><span class="token punctuation">;</span>
        <span class="token keyword">case</span> <span class="token string">&apos;rate&apos;</span><span class="token operator">:</span> <span class="token comment">//&#x6C47;&#x7387;&#x8BBE;&#x5B9A;&#xFF0C;&#x4FDD;&#x7559;&#x4E24;&#x4F4D;&#x5C0F;&#x6570;</span>
          rules<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span> <span class="token punctuation">{</span> validator<span class="token operator">:</span> isRate<span class="token punctuation">,</span> trigger<span class="token operator">:</span> <span class="token string">&apos;change&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token keyword">break</span><span class="token punctuation">;</span>
        <span class="token keyword">default</span><span class="token operator">:</span>
            rule<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">break</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
    <span class="token keyword">return</span> rules<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre>
<h5 id="websocketjs">webSocket.js</h5>
<p>webcoket&#x6587;&#x4EF6;&#xFF0C;&#x7528;&#x4E8E;&#x5934;&#x50CF;&#x83B7;&#x53D6;&#x4F7F;&#x7528;</p>
<pre class="language-"><code class="lang-javascript"><span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter">avatar<span class="token punctuation">,</span> callback<span class="token punctuation">,</span> error</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token comment">/* &#x5C01;&#x88C5; WebSocket &#x5B9E;&#x4F8B;&#x5316;&#x7684;&#x65B9;&#x6CD5;  */</span>
  <span class="token keyword">let</span> CreateWebSocket <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">return</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token parameter">urlValue</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">if</span> <span class="token punctuation">(</span>window<span class="token punctuation">.</span>WebSocket<span class="token punctuation">)</span> <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">WebSocket</span><span class="token punctuation">(</span>urlValue<span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token keyword">if</span> <span class="token punctuation">(</span>window<span class="token punctuation">.</span>MozWebSocket<span class="token punctuation">)</span> <span class="token keyword">return</span> <span class="token keyword">new</span> <span class="token class-name">MozWebSocket</span><span class="token punctuation">(</span>urlValue<span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token keyword">return</span> <span class="token boolean">false</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token comment">/* &#x5B9E;&#x4F8B;&#x5316; WebSocket &#x8FDE;&#x63A5;&#x5BF9;&#x8C61;, &#x5730;&#x5740;&#x4E3A; ws &#x534F;&#x8BAE; */</span>
  <span class="token keyword">let</span> webSocket <span class="token operator">=</span> <span class="token function">CreateWebSocket</span><span class="token punctuation">(</span><span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">ws://</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>location<span class="token punctuation">.</span>host<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">/ws/peer/avatar</span><span class="token template-punctuation string">`</span></span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token comment">/* &#x63A5;&#x6536;&#x5230;&#x670D;&#x52A1;&#x7AEF;&#x7684;&#x6D88;&#x606F;&#x65F6; */</span>
  webSocket<span class="token punctuation">.</span><span class="token function-variable function">onmessage</span> <span class="token operator">=</span> <span class="token parameter">msg</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
    <span class="token comment">// console.log(&quot;&#x670D;&#x52A1;&#x7AEF;&#x8BF4;:&quot; + msg.data);</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>msg <span class="token operator">&amp;&amp;</span> msg<span class="token punctuation">.</span>data<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">if</span> <span class="token punctuation">(</span>msg<span class="token punctuation">.</span>data <span class="token operator">!=</span> <span class="token string">&apos;false&apos;</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token function">callback</span><span class="token punctuation">(</span><span class="token punctuation">{</span>data<span class="token operator">:</span> msg<span class="token punctuation">.</span>data<span class="token punctuation">,</span> ws<span class="token operator">:</span> webSocket<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
        <span class="token keyword">let</span> wsData <span class="token operator">=</span> <span class="token punctuation">{</span>
          token<span class="token operator">:</span> localStorage<span class="token punctuation">.</span><span class="token function">getItem</span><span class="token punctuation">(</span><span class="token string">&quot;token&quot;</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          path<span class="token operator">:</span> avatar
        <span class="token punctuation">}</span>
        webSocket<span class="token punctuation">.</span><span class="token function">send</span><span class="token punctuation">(</span><span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">stringify</span><span class="token punctuation">(</span>wsData<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span><span class="token punctuation">;</span>
  <span class="token comment">/* &#x5173;&#x95ED;&#x65F6; */</span>
  webSocket<span class="token punctuation">.</span><span class="token function-variable function">onclose</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;&#x5173;&#x95ED;&#x8FDE;&#x63A5;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">;</span>
  webSocket<span class="token punctuation">.</span><span class="token function-variable function">onerror</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token parameter">err</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
    <span class="token function">error</span><span class="token punctuation">(</span>err<span class="token punctuation">)</span>
  <span class="token punctuation">}</span>
  <span class="token comment">/* &#x53D1;&#x9001;&#x6D88;&#x606F; */</span>
  <span class="token comment">// webSocket.send(str);</span>
  <span class="token comment">/* &#x5173;&#x95ED;&#x6D88;&#x606F; */</span>
  <span class="token comment">// webSocket.close();</span>
<span class="token punctuation">}</span>
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="styles.html" class="navigation navigation-prev " aria-label="Previous page: styles">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="views/" class="navigation navigation-next " aria-label="Next page: views">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"utils","level":"2.9","depth":1,"next":{"title":"views","level":"2.10","depth":1,"path":"src/views/README.md","ref":"src/views/README.md","articles":[{"title":"activate","level":"2.10.1","depth":2,"path":"src/views/activate.md","ref":"src/views/activate.md","articles":[]},{"title":"approvemanage","level":"2.10.2","depth":2,"path":"src/views/approvemanage.md","ref":"src/views/approvemanage.md","articles":[]},{"title":"sealmanage","level":"2.10.3","depth":2,"path":"src/views/sealmanage.md","ref":"src/views/sealmanage.md","articles":[]},{"title":"deptmanage","level":"2.10.4","depth":2,"path":"src/views/deptmanage.md","ref":"src/views/deptmanage.md","articles":[]},{"title":"faildoc","level":"2.10.5","depth":2,"path":"src/views/faildoc.md","ref":"src/views/faildoc.md","articles":[]},{"title":"files","level":"2.10.6","depth":2,"path":"src/views/files.md","ref":"src/views/files.md","articles":[]},{"title":"init","level":"2.10.7","depth":2,"path":"src/views/init.md","ref":"src/views/init.md","articles":[]},{"title":"layout","level":"2.10.8","depth":2,"path":"src/views/layout.md","ref":"src/views/layout.md","articles":[]},{"title":"login","level":"2.10.9","depth":2,"path":"src/views/login.md","ref":"src/views/login.md","articles":[]},{"title":"myfiles","level":"2.10.10","depth":2,"path":"src/views/myfiles.md","ref":"src/views/myfiles.md","articles":[]},{"title":"passmail","level":"2.10.11","depth":2,"path":"src/views/passmail.md","ref":"src/views/passmail.md","articles":[]},{"title":"redirect","level":"2.10.12","depth":2,"path":"src/views/redirect.md","ref":"src/views/redirect.md","articles":[]},{"title":"sysmanage","level":"2.10.13","depth":2,"path":"src/views/sysmanage.md","ref":"src/views/sysmanage.md","articles":[]},{"title":"template","level":"2.10.14","depth":2,"path":"src/views/template.md","ref":"src/views/template.md","articles":[]},{"title":"updateinfo","level":"2.10.15","depth":2,"path":"src/views/updateinfo.md","ref":"src/views/updateinfo.md","articles":[]},{"title":"usermanage","level":"2.10.16","depth":2,"path":"src/views/usermanage.md","ref":"src/views/usermanage.md","articles":[]}]},"previous":{"title":"styles","level":"2.8","depth":1,"path":"src/styles.md","ref":"src/styles.md","articles":[]},"dir":"ltr"},"config":{"plugins":["chapter-fold","-lunr","-search","search-pro","-highlight","prism"],"styles":{"website":"styles/website.css"},"pluginsConfig":{"prism":{"css":["prismjs/themes/prism-tomorrow.css"]},"chapter-fold":{},"search-pro":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Gj","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"合同管理","language":"zh-hans","gitbook":"3.2.3","description":"合同管理Web端"},"file":{"path":"src/utils.md","mtime":"2020-02-24T03:16:58.857Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-03-07T04:19:36.591Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

